Skip to content

Fix flaky config specs caused by STDERR.reopen#1832

Merged
viktorerlingsson merged 1 commit intomainfrom
feat/fix-config-spec-stderr-flakiness
Mar 26, 2026
Merged

Fix flaky config specs caused by STDERR.reopen#1832
viktorerlingsson merged 1 commit intomainfrom
feat/fix-config-spec-stderr-flakiness

Conversation

@viktorerlingsson
Copy link
Copy Markdown
Member

Summary

  • Add @io constructor param to Config (defaults to STDERR) and route all warning/error output through it
  • Specs that verify warning text now pass IO::Memory instead of using STDERR.reopen
  • Remove duplicate Config.initialize reopening in spec_helper.cr
  • Simplify Option struct by removing @deprecation_warn_msg and @io fields

Root cause

STDERR.reopen in the "log warning" specs corrupted Crystal's event loop fd registration for fd 2, causing intermittent File not open for writing errors in other config specs under --order random.

🤖 Generated with Claude Code

STDERR.reopen in the "log warning" specs corrupted Crystal's event
loop fd registration, causing intermittent "File not open for writing"
errors in other config specs when run in random order.

Add @io constructor param to Config (defaulting to STDERR) and route
all warning/error output through it. Specs that verify warning text
now pass an IO::Memory instead of redirecting STDERR.
@claude
Copy link
Copy Markdown

claude bot commented Mar 26, 2026

PR Review: No issues found.

The refactoring cleanly replaces STDERR redirection with dependency injection of an IO parameter on Config#initialize. The macro-generated closures correctly capture @io through self, the spec helper properly reopens the class with a public initializer, and the duplicate initializer at the bottom of spec_helper is correctly removed. Tests are updated accordingly.

Copy link
Copy Markdown
Member

@kickster97 kickster97 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

@viktorerlingsson viktorerlingsson marked this pull request as ready for review March 26, 2026 10:59
@viktorerlingsson viktorerlingsson requested a review from a team as a code owner March 26, 2026 10:59
@viktorerlingsson viktorerlingsson merged commit d0685dd into main Mar 26, 2026
18 checks passed
@viktorerlingsson viktorerlingsson deleted the feat/fix-config-spec-stderr-flakiness branch March 26, 2026 11:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants